package com.iflytek.iot.common.utils;

import java.util.UUID;

/**
 * @author zurun
 * @date 2018/10/7 23:52:34
 */
public class UUIDUtils {

    /**
     * 获取UUID
     *
     * @return
     */
    public static String uuid() {
        return UUID.randomUUID().toString();
    }

    /**
     * 去横线的uuid
     *
     * @return
     */
    public static String simpleUUID() {
        return UUID.randomUUID().toString().replace("-", "");
    }

    /**
     * version 3
     *
     * @param value
     * @return
     */
    public static long uniqueLongFromString(String value) {
        return UUID.nameUUIDFromBytes(value.getBytes()).getMostSignificantBits();
    }

    /**
     * unique id
     *
     * @param value
     * @return
     */
    public static long absUniqueLongFromString(String value) {
        long number = Math.abs(uniqueLongFromString(value));
        return number;
    }
}
